package com.htc.android.footprints.utils;

import android.content.Context;
import android.database.Cursor;
import android.os.SystemClock;
import android.util.Log;
import com.htc.android.footprints.provider.FootprintManager;
import com.htc.android.footprints.utils.camera.FootprintImageManager;
import com.htc.android.footprints.vo.Footprint;
import dalvik.system.VMRuntime;

public class PreloadDataRunnable
  implements Runnable
{
  private static final int CACHED_H = 50;
  private static final int CACHED_W = 50;
  private static final String KEY = "ListModeActivity";
  public static final String TAG = "PreloadDataRunnable";
  private static final String sortBy = "create_time desc";
  private Footprint[] footprints = null;
  private FootprintManager mDbManager;
  private FootprintImageManager mImageManager;
  private boolean mIsPreloading = true;
  private PreloadListener mPreloadListener = null;

  public PreloadDataRunnable(Context paramContext, Footprint[] paramArrayOfFootprint)
  {
    this.mDbManager = FootprintManager.getInstance(paramContext);
    this.mImageManager = FootprintImageManager.getInstance();
    if ((paramArrayOfFootprint != null) && (paramArrayOfFootprint.length > 0))
      this.footprints = paramArrayOfFootprint;
  }

  private void preloadPhoto(String paramString)
  {
    if ((paramString == null) || (paramString.length() == 0));
    while (true)
    {
      return;
      if (this.mImageManager.cachedScaledFastImage("ListModeActivity", 50, 50, paramString))
        continue;
    }
  }

  /** @deprecated */
  public boolean getPreloadingStatus()
  {
    monitorenter;
    try
    {
      boolean bool = this.mIsPreloading;
      monitorexit;
      return bool;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public void run()
  {
    long l = SystemClock.elapsedRealtime();
    if (this.footprints == null)
    {
      Cursor localCursor = this.mDbManager.findFootprintCursorByCategory(null, "create_time desc");
      while (true)
        if ((localCursor != null) && (localCursor.getCount() > 0) && (localCursor.moveToNext()) && (this.mIsPreloading))
          try
          {
            Thread.sleep(10L);
            preloadPhoto(localCursor.getString(localCursor.getColumnIndexOrThrow("pic_path")));
          }
          catch (InterruptedException localInterruptedException)
          {
            while (true)
              localInterruptedException.printStackTrace();
          }
      localCursor.close();
    }
    while (true)
    {
      this.mDbManager = null;
      this.mImageManager = null;
      this.footprints = null;
      if (this.mPreloadListener != null)
        this.mPreloadListener.preloadCompete(true);
      Log.d("PreloadDataRunnable", "end preloading :" + (SystemClock.elapsedRealtime() - l));
      Log.d("PreloadDataRunnable", "end preloading externalByte:" + VMRuntime.getRuntime().getExternalBytesAllocated());
      do
        return;
      while ((this.footprints == null) || (this.footprints.length == 0));
      for (Footprint localFootprint : this.footprints)
      {
        if (!this.mIsPreloading)
          continue;
        preloadPhoto(localFootprint.mPicPath);
      }
    }
  }

  public void setPreloadListener(PreloadListener paramPreloadListener)
  {
    if (paramPreloadListener != null)
      this.mPreloadListener = paramPreloadListener;
  }

  /** @deprecated */
  public void stopPreloading()
  {
    monitorenter;
    try
    {
      this.mIsPreloading = false;
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public static abstract interface PreloadListener
  {
    public abstract void preloadCompete(boolean paramBoolean);
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.utils.PreloadDataRunnable
 * JD-Core Version:    0.6.0
 */